<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="com.google.appengine.api.datastore.*"%>
<%@ page import="java.util.*"%>
<%@ page import="org.feeddreamwork.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="/includes/head.jsp"%>
<title>FeedDreamwork - 升级</title>
</head>
<body>
<%@ include file="/includes/top.jsp"%>
<div id="menu">
<ul>
	<li><a href="/">主页</a></li>
	<li><a href="/settings/listfeed.jsp">我的 Feed</a></li>
	<li><a href="/settings/addfeed.jsp">添加 Feed</a></li>
	<li class="active"><a href="/admin/admin.jsp">管理员工具</a></li>
	<%@ include file="/includes/userinfo.jsp"%>
</ul>
</div>
<%
	FeedInfoRepository feedInfoRepo = new FeedInfoRepository();
	List <FeedInfo> feedInfos = feedInfoRepo.getFeedInfos();
	for (FeedInfo feedInfo : feedInfos) {
		List <String> processors = new ArrayList <String> ();
		for (String command : feedInfo.getProcessors()) {
			if (command.startsWith("addafter")) {
				processors.add("addafter description" + command.replaceFirst("addafter", ""));
				continue;
			}
			if (command.startsWith("addbefore")) {
				processors.add("addbefore description" + command.replaceFirst("addbefore", ""));
				continue;
			}
			if (command.startsWith("remove") && !command.startsWith("removeredundancy")) {
				String [] params = command.split(" ");
				processors.add(params[0] + " description" + command.replaceFirst(params[0], ""));
				continue;
			}
			if (command.startsWith("replace")) {
				processors.add("replace description" + command.replaceFirst("replace", ""));
				continue;
			}
			processors.add(command);
		}
		for (String command : processors)
			System.out.println(command);
		System.out.println();
		feedInfo.setProcessors(processors);
		feedInfoRepo.saveObject(feedInfo);
	}
	feedInfoRepo.close();
%>
<div id="page">
<h1>升级成功!</h1>
</div>
<%@ include file="/includes/footer.jsp"%>
</body>
</html>
